from selenium import webdriver
import time


class TestCase:
    def __init__(self):
        self.driver = webdriver.Chrome()

    def window_size(self):
        time.sleep(2)
        self.driver.set_window_size(480, 700)
        time.sleep(2)

        # 最大化、
        self.driver.maximize_window()
        time.sleep(1)
        # 最小化
        self.driver.minimize_window()
        time.sleep(1)

    def refresh(self):
        self.driver.get('https://www.so.com')
        time.sleep(1)
        self.driver.refresh()
        time.sleep(1)

    def forward_back(self):
        self.driver.get('https://www.so.com')
        time.sleep(1)
        self.driver.back()
        time.sleep(1)
        self.driver.forward()

    def close(self):
        self.driver.get('https://www.so.com')
        time.sleep(3)
        self.driver.find_element_by_link_text('问答').click()

        time.sleep(3)
        self.driver.close()

    def quit(self):
        time.sleep(3)
        self.driver.quit()



if __name__ == '__main__':
    case = TestCase()

    # 窗口大小
    # case.window_size()

    # 刷新
    # case.refresh()

    # 前进后退
    # case.forward_back()

    # 关闭当前
    case.close()

    case.quit()
